package com.ruoyi.web.controller.dr;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dr.domain.DrHome;
import com.ruoyi.dr.service.IDrHomeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 达人主页 /square_pc_api/homePage/author/profileController
 * 
 * @author ruoyi
 * @date 2025-07-12
 */
@RestController
@RequestMapping("/dr/home")
public class DrHomeController extends BaseController
{
    @Autowired
    private IDrHomeService drHomeService;

    /**
     * 查询达人主页 /square_pc_api/homePage/author/profile列表
     */
    @PreAuthorize("@ss.hasPermi('dr:home:list')")
    @GetMapping("/list")
    public TableDataInfo list(DrHome drHome)
    {
        startPage();
        List<DrHome> list = drHomeService.selectDrHomeList(drHome);
        return getDataTable(list);
    }

    /**
     * 导出达人主页 /square_pc_api/homePage/author/profile列表
     */
    @PreAuthorize("@ss.hasPermi('dr:home:export')")
    @Log(title = "达人主页 /square_pc_api/homePage/author/profile", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DrHome drHome)
    {
        List<DrHome> list = drHomeService.selectDrHomeList(drHome);
        ExcelUtil<DrHome> util = new ExcelUtil<DrHome>(DrHome.class);
        util.exportExcel(response, list, "达人主页 /square_pc_api/homePage/author/profile数据");
    }

    /**
     * 获取达人主页 /square_pc_api/homePage/author/profile详细信息
     */
    @PreAuthorize("@ss.hasPermi('dr:home:query')")
    @GetMapping(value = "/{uid}")
    public AjaxResult getInfo(@PathVariable("uid") String uid)
    {
        return success(drHomeService.selectDrHomeByUid(uid));
    }

    /**
     * 新增达人主页 /square_pc_api/homePage/author/profile
     */
    @PreAuthorize("@ss.hasPermi('dr:home:add')")
    @Log(title = "达人主页 /square_pc_api/homePage/author/profile", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DrHome drHome)
    {
        return toAjax(drHomeService.insertDrHome(drHome));
    }

    /**
     * 修改达人主页 /square_pc_api/homePage/author/profile
     */
    @PreAuthorize("@ss.hasPermi('dr:home:edit')")
    @Log(title = "达人主页 /square_pc_api/homePage/author/profile", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DrHome drHome)
    {
        return toAjax(drHomeService.updateDrHome(drHome));
    }

    /**
     * 删除达人主页 /square_pc_api/homePage/author/profile
     */
    @PreAuthorize("@ss.hasPermi('dr:home:remove')")
    @Log(title = "达人主页 /square_pc_api/homePage/author/profile", businessType = BusinessType.DELETE)
	@DeleteMapping("/{uids}")
    public AjaxResult remove(@PathVariable String[] uids)
    {
        return toAjax(drHomeService.deleteDrHomeByUids(uids));
    }
}
